package cn.itcast.star.graph.core.controller;

import cn.itcast.star.graph.core.dto.UserLoginRequestDTO;
import cn.itcast.star.graph.core.dto.UserLoginResponseDTO;
import cn.itcast.star.graph.core.dto.common.Result;
import cn.itcast.star.graph.core.service.UserService;
import cn.itcast.star.graph.core.utils.UserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/1.0/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 登录请求
     * @param userLoginRequestDTO
     * @return
     */
    @PostMapping("/login")
    public Result<UserLoginResponseDTO> login(@RequestBody UserLoginRequestDTO userLoginRequestDTO) {
        return Result.ok(userService.login(userLoginRequestDTO));
    }

    @PostMapping("/list")
    public String list() {
        System.out.println("用户ID是：" + UserUtil.getUser().getId());
        return "hello";
    }
}
